from PyQt5.Qt import *
import sys



class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("布局管理-初始QLayout")
        self.resize(600,400)
        self.addLabels()
        self.setBackImg()

    def addLabels(self):
        lb1 = QLabel('区域1',self)
        lb1.setStyleSheet("""
        background-color:red;
        """)
        lb2 = QLabel('区域2', self)
        lb2.setStyleSheet("""
              background-color:green;
              """)
        lb3 = QLabel('区域3', self)
        lb3.setStyleSheet("""
              background-color:blue;
              """)
        le1 = QLineEdit(self)
        le1.setFixedHeight(60)
        le1.setPlaceholderText("请输入你的用户名")
        le2 = QLineEdit(self)
        le2.setFixedHeight(60)
        le2.setPlaceholderText("请输入你的密码")
        bn = QPushButton(self)
        bn.setFixedHeight(60)
        bn.setText("登录")

        v_layout = QVBoxLayout()
        v_layout.setContentsMargins(80,100,80,60)
        v_layout.setSpacing(20)
        self.setLayout(v_layout)
        v_layout.addWidget(le1)
        v_layout.addWidget(le2)
        v_layout.addWidget(bn)
    def setBackImg(self):
        palette  = QPalette()
        palette.setBrush(QPalette.Background,QBrush(QPixmap(r'./hqu.jpeg')))
        self.setPalette(palette)



if __name__=='__main__':
    app = QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())